<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var sortedSquares = function(nums) {
				nums.sort((a, b) => Math.abs(a) - Math.abs(b));
				for (let i = 0; i < nums.length; i++) {
					nums[i] = Math.pow(nums[i], 2);
				}
				return nums
			};
			console.log(sortedSquares([-4, -1, 0, 3, 10]));
		</script>
	</body>
</html>
